Skip to content

SVG: apply CSS rules with a universal or element selector - #2181

Open
RavSinghChandan wants to merge 5 commits into
py-pdf:masterfrom
RavSinghChandan:svg-css-type-selectors
Open

RavSinghChandan wants to merge 5 commits into
py-pdf:masterfrom
RavSinghChandan:svg-css-type-selectors

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Only .class rules are read from a <style>, so * { ... } and rect { ... } are dropped. Every SVG that matplotlib writes starts with:

*{stroke-linejoin: round; stroke-linecap: butt}

_extract_css_rules() now returns every rule, _extract_css_class_styles() keeps the class ones from it, and rules for * and element names are kept in css_type_styles. _style_map_for() applies them before class rules and inline styles, in the order of CSS specificity.

test_svg_css_type_and_universal_selectors covers the cascade against attributes, inline styles and class rules; test_svg_css_universal_selector_of_matplotlib covers the matplotlib rule. path_clippingpath.svg is a matplotlib figure with that rule, so its reference PDF is regenerated: its strokes get round joins, and every coordinate stays the same.

Only .class rules were read from a <style>, so * { ... } and rect { ... }
were dropped; every matplotlib SVG starts with
*{stroke-linejoin: round; stroke-linecap: butt}. _extract_css_rules()
now returns every rule, _extract_css_class_styles() keeps the class
ones, and the * and element rules apply before class rules, as CSS
specificity orders them.
The sample is a matplotlib figure whose <style> holds
*{stroke-linejoin: round; stroke-linecap: butt}; only the line join of
its strokes changes, every coordinate is the same.
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants